var utils = require("../lib/Utils");


exports.userShareUrl = function (req,res,next) {
    var userId = req.query.userId;

    var param = {
        userId:userId
    }

    utils.httpPost("/delivery/getShareUrl", param, function (data) {
        console.log(data);
        if(data.code == '200'){
            res.render('delivery/share',{title:'分享',shareUrl:data.data.url,shareText:data.data.nickName});
        }else {
            res.render('delivery/error',{title:'出错啦!'});
        }
    });


}

exports.kf = function (req,res,next) {
    res.render('delivery/kf',{title:'鲜速生活客服'});
}


exports.waitOrd = function (req,res,next) {
    res.render('delivery/waitord',{title:'订单列表'});
}

exports.getOrds = function (req,res,next) {
    var param = {
        openId:1
    }
    utils.httpPost("/delivery/getWaitOrds", param, function (data) {
        console.log(data);
        res.status(200).end(JSON.stringify(data));
    });


}

exports.ordDtl = function (req,res,next) {
    var orderId = req.query.orderId;
    res.render('delivery/ordDtl',{title:'订单明细',orderId:orderId});
}

exports.getDetails = function (req,res,next) {
    var orderId = req.body.orderId;

    utils.httpPost("/delivery/getWaitOrdDtls", {orderId:orderId}, function (data) {
        console.log(data);
        res.status(200).end(JSON.stringify(data));
    });
}